package cn.edu.sasu.common.base;

import java.io.Serializable;

/**
 * 支持layui格式
 */
public class LayuiRespResult<T> implements Serializable {
    // 状态码
    private Integer code = RespResultCode.OK.getCode();
    // 消息
    private String msg = RespResultCode.OK.getMessage();
    // 总条数
    private Integer count;
    /**
     * 返回结果的数据对象
     */
    private T data;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Integer getCount() {
        return count;
    }

    public void setCount(Integer count) {
        this.count = count;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public LayuiRespResult(IRespResultCode respResultCode) {
        this.code = respResultCode.getCode();
        this.msg = respResultCode.getMessage();
    }

    public static <T> LayuiRespResult<T> success(Integer count,T data) {
        LayuiRespResult<T> lar = new LayuiRespResult<T>(RespResultCode.OK);
        lar.setCount(count);
        lar.setData(data);
        return lar;
    }


}
